<template>
    <div class="row">
        <el-checkbox v-model="comp.enabled">{{ comp.__classname__ }}</el-checkbox>
        <el-button round size="small" :icon="Document" @click="gm.toConsole(comp)"></el-button>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Type</el-text>
        <el-select v-model="comp.type" size="small">
            <el-option v-for="item in type.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start" v-if="comp.type == type.HORIZONTAL">
        <el-text class="span-title" truncated>AlignHorizontal</el-text>
        <el-checkbox v-model="comp.alignHorizontal" />
    </div>
    <div class="row-start" v-if="comp.type == type.VERTICAL">
        <el-text class="span-title" truncated>AlignVertical</el-text>
        <el-checkbox v-model="comp.alignVertical" />
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>ResizeMode</el-text>
        <el-select v-model="comp.resizeMode" size="small">
            <el-option v-for="item in resizeMode.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start" v-if="comp.type == type.GRID">
        <el-text class="span-title" truncated>StartAxis</el-text>
        <el-select v-model="comp.startAxis" size="small">
            <el-option v-for="item in startAxis.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start" v-if="comp.type == type.GRID || comp.type == type.HORIZONTAL">
        <el-text class="span-title" truncated>PaddingLR</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.paddingLeft">
            <template #suffix>
                <span>Left</span>
            </template>
        </el-input-number>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.paddingRight">
            <template #suffix>
                <span>Right</span>
            </template>
        </el-input-number>
    </div>
    <div class="row-start" v-if="comp.type == type.GRID || comp.type == type.VERTICAL">
        <el-text class="span-title" truncated>PaddingTB</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.paddingTop">
            <template #suffix>
                <span>Top</span>
            </template>
        </el-input-number>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.paddingBottom">
            <template #suffix>
                <span>Bottom</span>
            </template>
        </el-input-number>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>Spacing</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.spacingX" v-if="comp.type == type.GRID || comp.type == type.HORIZONTAL">
            <template #suffix>
                <span>X</span>
            </template>
        </el-input-number>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.spacingY" v-if="comp.type == type.GRID || comp.type == type.VERTICAL">
            <template #suffix>
                <span>Y</span>
            </template>
        </el-input-number>
    </div>

    <div class="row-start" v-if="comp.type == type.GRID || comp.type == type.VERTICAL">
        <el-text class="span-title" truncated>VerticalDirection</el-text>
        <el-select v-model="comp.verticalDirection" size="small">
            <el-option v-for="item in verticalDirection.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>
    <div class="row-start" v-if="comp.type == type.GRID || comp.type == type.HORIZONTAL">
        <el-text class="span-title" truncated>HorizontalDirection</el-text>
        <el-select v-model="comp.horizontalDirection" size="small">
            <el-option v-for="item in horizontalDirection.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>
    
    <div class="row-start" v-if="comp.type == type.GRID || comp.type == type.HORIZONTAL">
        <el-text class="span-title" truncated>Constraint</el-text>
        <el-select v-model="comp.constraint" size="small">
            <el-option v-for="item in constraint.__enums__" :key="item.value" :label="item.name" :value="item.value" />
        </el-select>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>AffectedByScale</el-text>
        <el-checkbox v-model="comp.affectedByScale" />
    </div>
</template>

<script lang="ts" setup>
import { Document } from '@element-plus/icons-vue'
import gm from './gm';

defineProps<{
    comp: CCComponent,
    update: Number,
}>()
const type = cc.Layout.Type
const resizeMode = cc.Layout.ResizeMode
const horizontalDirection = cc.Layout.HorizontalDirection
const verticalDirection = cc.Layout.VerticalDirection
const startAxis = cc.Layout.AxisDirection
const constraint = cc.Layout.Constraint
</script>